package com.example.wordlistdemo;

import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;
import com.example.wordlistdemo.entity.EcEntiity;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class HobbiesDeserializer implements ObjectDeserializer {

    @Override
    public List<EcEntiity.WordForm> deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
        // 自定义逻辑，如果数组为空，则返回默认值
        List<EcEntiity.WordForm> array = parser.parseObject(List.class);
        if(array == null || array.size() == 0){
            return new ArrayList<>();
        }
        return array;
    }

    @Override
    public int getFastMatchToken() {
        return 0;
    }
}
